home *** CD-ROM | disk | FTP | other *** search
- ///////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////
- // This example code is from the book:
- //
- // Object-Oriented Programming with C++ and OSF/Motif
- // by
- // Douglas Young
- // Prentice Hall, 1992
- // ISBN 0-13-630252-1
- //
- // Copyright 1991 by Prentice Hall
- // All Rights Reserved
- //
- // Permission to use, copy, modify, and distribute this software for
- // any purpose except publication and without fee is hereby granted, provided
- // that the above copyright notice appear in all copies of the software.
- ///////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////
-
-
- ////////////////////////////////////////////////////////
- // pushme.C, Using callback functions in C++
- ////////////////////////////////////////////////////////
- #include <stdlib.h> // Needed for exit prototype
- #include <Xm/Xm.h>
- #include <Xm/PushB.h>
-
- static void quitCallback ( Widget, XtPointer, XtPointer );
-
- #if (XlibSpecificationRelease>=5)
- void main ( int argc, char **argv )
- #else
- void main ( unsigned int argc, char **argv )
- #endif
- {
- Widget button, toplevel;
- XtAppContext app;
- XmString xmstr;
-
- // Initialize the Intrinsics
-
- toplevel = XtAppInitialize ( &app, "Pushme", NULL, 0,
- &argc, argv, NULL, NULL, 0 );
-
- // Create a compound string
-
- xmstr = XmStringCreateSimple ( "Push Me" );
-
- // Create an XmPushButton widget to display the string
-
- button = XtVaCreateManagedWidget ( "button",
- xmPushButtonWidgetClass,
- toplevel,
- XmNlabelString, xmstr,
- NULL );
-
- // Free the compound string after the XmPushButton has copied it.
-
- XmStringFree ( xmstr );
-
- // Register the quitCallback callback function
- // to be called when the button is pushed
-
- XtAddCallback ( button,
- XmNactivateCallback,
- quitCallback,
- NULL ); // No client data needed
-
- // Realize all widgets and enter the main event loop
-
- XtRealizeWidget ( toplevel );
- XtAppMainLoop ( app );
- }
-
- // Callback invoked when button is activated
-
- void quitCallback ( Widget w, XtPointer, XtPointer )
- {
- exit ( 0 );
- }
-
-